#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct List{
  int Coe;
  int Exp;
  struct List*next;
};
int main(){
  List *L,*p,*q;
  int coe,exp,i=0;
  L=(List *)malloc(sizeof(List));
  L->next=NULL;
  p=L;

    while(cin>>coe>>exp){
    	if(coe==0||exp==0) {
    	q=(List *)malloc(sizeof(List));
		q->Coe=0;
		q->Exp=0;
		p->next=q;
		q->next=NULL;
		i++;
		break;
    	}
    q=(List *)malloc(sizeof(List));
    if(coe&&exp) {
    	q->Coe=coe*exp;
		q->Exp=exp-1;
        p->next=q;
        p=q;
		i++; 
    }
    p->next=NULL;
}
    p=L->next;
	if(i==1&&!p->Coe||p->Coe) cout<<p->Coe<<" "<<p->Exp;
	p=p->next;
  while(p){
  	if(p->Coe) cout<<" "<<p->Coe<<" "<<p->Exp;
    p=p->next;
  }
  return 0;
}
